home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8168 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  853 b 

  1. Path: tech.cftnet.com!not-for-mail
  2. From: wcowley@cftnet.com (Wes Cowley)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Constructors for objects that can be FALSE
  5. Date: 15 Feb 1996 11:17:49 GMT
  6. Organization: CFTnet
  7. Message-ID: <4fv4ou$l4t@tech.cftnet.com>
  8. References: <4fusaq$g1e@due.unit.no>
  9. NNTP-Posting-Host: ppp244_4.cftnet.com
  10. X-Newsreader: TIN [UNIX 1.3 950824BETA PL0]
  11.  
  12. Rolf Rustad (rustad@fm.unit.no) wrote:
  13.  
  14. : What I would like is to make objects of these classes evaluate to FALSE
  15. : if the physical device is not present or available, as do for instanse 
  16. : ifpstream:
  17. :  ifpstream is(filename); 
  18. :  if(!is){
  19. :  .
  20. :  .
  21. :  }
  22. : How do I write the constructor??
  23.  
  24. One possibility is to have the constructor store some indication of the 
  25. status of the device.  Then provide an operator int() that returns a 
  26. result that can be tested in the if.
  27.  
  28. Wes
  29.  
  30.